#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int countSubarrays(vector<int>& nums) {
        int res = 0;
        for (int end = 2; end < nums.size(); end++)
        {
            if ((nums[end] + nums[end - 2]) * 2 == nums[end - 1])
                ++res;
        }
        return res;
    }
};